package com.hhkj.api.order.controller;

import com.hhkj.admin.order.model.req.OrderItemReq;
import com.hhkj.admin.train.model.dopo.TrainDo;
import com.hhkj.admin.train.service.base.TrainService;
import com.hhkj.api.order.model.req.ApiOrderItemCheckReq;
import com.hhkj.api.order.model.req.ApiOrderItemReq;
import com.hhkj.api.order.service.biz.ApiOrderItemBizService;
import com.hhkj.api.sale.common.session.model.LoginSale;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.framework.login.api.ApiLogin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ApiOrderItemController
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/10/31 15:36
 */
@RestController
@RequestMapping("/api/sale/order/item")
public class ApiOrderItemController extends BaseController {

    @Autowired
    private ApiOrderItemBizService itemBizService;

    /** 列表 */
    @ApiLogin(LoginSale.class)
    @PostMapping("/list")
    public TableDataInfo list(@Validated @RequestBody ApiOrderItemReq req) {
        return getDataTable(itemBizService.list(req));
    }

    /** 校验信息 */
    @ApiLogin(LoginSale.class)
    @PostMapping("/check")
    public AjaxResult check(@Validated @RequestBody ApiOrderItemCheckReq req) {
        itemBizService.check(req);
        return AjaxResult.success();
    }

    @ApiLogin(LoginSale.class)
    @PostMapping("/student/train/list")
    public TableDataInfo studentTrainList(@RequestBody ApiOrderItemReq apiOrderItemReq) {
        return getDataTable(itemBizService.listStudentTrain(apiOrderItemReq));
    }
}
